<template>
	<div class="rules_modifyCon">
		
		<!--转发数据的修改-->
		<div class="rules_modify">
		<el-dialog title="修改处理数据信息" :visible.sync="modifyCcont" >
		 <el-form :model="form1" :rules="rules" ref="form1"  class="demo-ruleForm">
				<el-form-item label="规则查询语句：" :label-width="formLabelWidth" >
						 <span>SELECT FROM "iot/address/user/thing/hellotopic"</span>
				</el-form-item>
				 <el-form-item label="字段：" :label-width="formLabelWidth" readonly prop="ming">
						<el-input v-model="form1.ming"  auto-complete="off" style="width:60%"></el-input>
				</el-form-item>
				<el-form-item label="topic：" :label-width="formLabelWidth"  prop="state">
					 <el-select v-model="form1.state" placeholder="请选择" style="width:60%">
							<el-option label="转发至另外的TOPIC" value="转发至另外的TOPIC"></el-option>
							<el-option label="转发至MYSQL" value="转发至MYSQL"></el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="条件：" :label-width="formLabelWidth" prop="desc">
					<el-input v-model="form1.desc"  auto-complete="off" style="width:60%"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="modifyCcont=false">取消</el-button>
				<el-button type="primary" @click="submitform('form1')">确 定</el-button>
			</div>
		</el-dialog>
		</div>
	</div>
</template>
<script>
import bus from '../../eventBus.js'
export default{
	name:'modify',
		
	data(){
		return{
			modifyCcont:false,
			formLabelWidth:"150px",
			form1:{
				ming:'temperature',
				desc:'temperature>=8',
				state:""
			},
			addForm:{
				msg:'',
			},
			rules:{
				ming:[
					{required:true,message:'名称不能为空！',trigger:'blur'},
				],
				desc:[
					{required:true,message:'设备描述不能为空',trigger:'blur'},
				],				
				state:[{required:true,message:'请选择规则状态',trigger:'change'}]
			},
		}
	},
	methods:{
		submitform(formName){
			// console.log(this.form1);
			//           this.modifyCcont=false;
			this.$refs[formName].validate((valid) => {
				if (valid) {
					console.log(this.form1);
					this.modifyCcont=false;
				} else {
					console.log('error submit!!');
					return false;
				}
			});
		}
	},
	mounted(){
		var self=this;
		bus.$on("modifyCcont",function (msg) {
			self.modifyCcont=msg;
		});
	}
}
</script>

<style>


</style>